﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PaDgame;

namespace PaDgame
{
	public class JudgeManager : MonoBehaviour
	{
		public FirstController sceneController;

		protected void Start()
		{
			sceneController = (FirstController)SSDirector.getInstance().currentSceneController;
			sceneController.judgeManager = this;
		}

		public int judgeWinOrLose()
		{
			int fromPriest = 0;
			int fromDevil = 0;
			int toPriest = 0;
			int toDevil = 0;

			int[] fromCount = sceneController.fromBank.getCharacterNum();
			fromPriest += fromCount[0];
			fromDevil += fromCount[1];

			int[] toCount = sceneController.toBank.getCharacterNum();
			toPriest += toCount[0];
			toDevil += toCount[1];

			if (toPriest == 3 && toDevil == 3)
				return 2;

			int[] boatCount = sceneController.boat.getCharacterNum();
			if (sceneController.boat.getToOrFrom() == -1)
			{
				toPriest += boatCount[0];
				toDevil += boatCount[1];
			}
			else
			{
				fromPriest += boatCount[0];
				fromDevil += boatCount[1];
			}
			if (fromPriest < fromDevil && fromPriest > 0)
			{
				return 1;
			}
			if (toPriest < toDevil && toPriest > 0)
			{
				return 1;
			}
			return 0;
		}
	}
}

